<?php
class HomeController extends Apps_Controller_Action_Default {

    public function indexAction() {
//         $tbProduct = new Model_DbTable_Product();
//         // List featured product
//         $featuredProduct = $tbProduct->fetchAll(array('is_featured =?' => $tbProduct::STATUS_ACTIVE, 'status =?' => $tbProduct::STATUS_ACTIVE),
//                                                 array('ASC' => 'sorting_number'));

//         $this->view->featuredProduct = $featuredProduct;

//         // List best selling product
//         $bestSellingProduct = $tbProduct->fetchAll(array('is_best_selling =?' => $tbProduct::STATUS_ACTIVE, 'status =?' => $tbProduct::STATUS_ACTIVE),
//                                                    array('ASC' => 'sorting_number'));

//         $this->view->bestSellingProduct = $bestSellingProduct;



        // Product new
        $dbAdapter = Zend_Db_Table::getDefaultAdapter();
        $select = $dbAdapter
                    ->select()
                    ->from('product', null)
                    ->join('product_category', 'product_category.id = product.product_category_id', null)
                    ->where('product.status =? ', Model_DbTable_Product::STATUS_ACTIVE)
                    ->where('product.is_new =? ', Model_DbTable_Product::STATUS_ACTIVE)
                    ->where('product_category.status =?', Model_DbTable_ProductCategory::STATUS_ACTIVE)
                    ->columns(array(
                            'id' => 'product.id',
                            'name' => 'product.name',
                            'code' => 'product.code',
                            'price_sale' => 'product.price_sale',
                            'thumbnail_link' => 'product.thumbnail_link'
                    ));
        $products = $select->query()->fetchAll();
        $this->view->products = $products;

         // List supporter
         $tbSupport = new Model_DbTable_Support();
         $support = $tbSupport->fetchAll(array('status =?' => $tbSupport::STATUS_ACTIVE), array('ASC' => 'sorting_number'));

         $this->view->support = $support;
    }
}